*************************************
* Appendix F ************************
* Robustness Checks *****************
*************************************


run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year <2013

* Table F.1 altnerative measure of promotion

global full_spc_alter_dv  keep($interaction ) lab  nocons  dec(3)

reghdfe sec_promotion_fat $interaction   $i_control   ,  absorb(year cityID) cluster(cityID)
outreg2 using "alternativeprom.tex", replace $full_spc_alter_dv ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N )

reghdfe sec_promotion_fat $interaction  $p_control $i_control  ,  absorb(year cityID) cluster(cityID)
outreg2 using "alternativeprom.tex", append  $full_spc_alter_dv ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N )


reghdfe sec_promotion_fat $interaction  $prov_control $p_control  $i_control  ,  absorb(year cityID) cluster(cityID)
outreg2 using "alternativeprom.tex", append  $full_spc_alter_dv ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y )


* Table F.2 ratio measure

g purge_ratio_con = first_con_ps*purge_cen_ratio
lab var purge_cen_ratio "Purge of CM Officials (Ratio)"
lab var purge_ratio_con "Purge of CM Officials (Ratio)*Connection"
global ratio_inter purge_ratio_con first_con_ps purge_cen_ratio 
global full_spc_ratio  keep($ratio_inter  ) lab  nocons  dec(3)   

reghdfe  sec_promotion $ratio_inter  $i_control   ,  absorb(year cityID) cluster(cityID)
outreg2 using "ratio.tex", replace  $full_spc_ratio  ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N )

reghdfe  sec_promotion $ratio_inter  $p_control $i_control  ,  absorb(year cityID) cluster(cityID)
outreg2 using "ratio.tex", append $full_spc_ratio addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N )


reghdfe  sec_promotion $ratio_inter  $prov_control $p_control  $i_control   ,  absorb(year cityID) cluster(cityID)
outreg2 using "ratio.tex", append   $full_spc_ratio addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y )


* Table F.3 alternative measure of connections
 
reghdfe sec_promotion c.con_home##c.purge_cen_cum    $prov_control $p_control  $i_control   ,  absorb(year cityID) cluster(cityID)
est store m1

reghdfe sec_promotion c.con_college##c.purge_cen_cum    $prov_control $p_control  $i_control  ,  absorb(year cityID) cluster(cityID)
est store m2

reghdfe sec_promotion  c.con_ps##c.purge_cen_cum   $prov_control $p_control  $i_control   ,  absorb(year cityID) cluster(cityID)
est store m3

outreg2 [m1 m2 m3] using "alternative_con.tex", replace  drop($p_control $prov_control  $i_control) ///
lab  nocons  dec(3)     ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y)

* Table F.4 Provincial SE

global full_spc_baseline  keep($interaction) lab  nocons  dec(3)   // alpha(0.01, 0.05, 0.1)

reghdfe  sec_promotion first_con_ps  $i_control ,  absorb(year cityID) cluster(provID)
outreg2 using "prov_se.tex", replace  $full_spc_baseline ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N )

reghdfe  sec_promotion first_con_ps $p_control $i_control ,  absorb(year cityID ) cluster(provID)
outreg2 using "prov_se.tex", append  $full_spc_baseline ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N )


reghdfe  sec_promotion $interaction   $i_control  ,  absorb(year cityID) cluster(provID)
outreg2 using "prov_se.tex", append  $full_spc_baseline ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N )


reghdfe  sec_promotion $interaction  $p_control $i_control ,  absorb(year cityID) cluster(provID)
outreg2 using "prov_se.tex", append  $full_spc_baseline  ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N )


reghdfe  sec_promotion $interaction  $prov_control $p_control  $i_control ,  absorb(year cityID ) cluster(provID)
outreg2 using "prov_se.tex", append  $full_spc_baseline ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y )


* Table F.5 bootstrap se
set seed 2022
global spc_bootstrap   keep($interaction ) lab  nocons  dec(3) 

xtreg sec_promotion $interaction  $i_control i.year ,fe cluster(cityID)
boottest purgeconnection ,boot(wild)

outreg2 using "bootstrap.tex", replace $spc_bootstrap ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N )


xtreg sec_promotion $interaction  $p_control $i_control i.year ,fe cluster(cityID)

boottest purgeconnection ,boot(wild)

outreg2 using "bootstrap.tex", append $spc_bootstrap  ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N )

xtreg sec_promotion $interaction $prov_control $p_control $i_control i.year ,fe cluster(cityID)
outreg2 using "bootstrap.tex", append  $spc_bootstrap ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y )
boottest purgeconnection ,boot(wild)

* Table A.6 probit model
global full_spc lab  nocons  dec(3)  

probit sec_promotion $interaction  i.year ,  cluster(cityID)
outreg2 using "probit.tex", replace $spc_bootstrap ///
addtext(Prefecture and Year FE, Y, Individual Controls, N, Prefectural Controls, N, Provincial Controls, N )


probit sec_promotion $interaction  $i_control  i.year   ,   cluster(cityID)
outreg2 using "probit.tex", append $spc_bootstrap ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N )

probit sec_promotion $interaction  $i_control   $p_control  i.year  ,  cluster(cityID)
outreg2 using "probit.tex", append $spc_bootstrap ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N )

probit sec_promotion $interaction $prov_control $p_control   $i_control  ,  cluster(cityID)
outreg2 using "probit.tex", append $spc_bootstrap ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y )
 

** Figure F.1 marginal effect plot of probit model

probit sec_promotion  i.first_con_ps##c.purge_cen_cum $prov_control $p_control    $i_control  ,  cluster(cityID)

margins ,dydx(first_con_ps) at(purge_cen_cum = (0(1)9))

marginsplot, plot1opts(lcolor(gs8)) ciopt(color(black%20)) yline(0)  title("") xtitle("Purge Intensity") ytitle("Effect of Connections on Political Turnover") 

graph  export  "/Users/zerenli1992/Dropbox/Apps/Overleaf/li_manion_2020/mplot_probit.png",  replace




*Table F.7 subsample analysis

reghdfe sec_promotion $interaction $prov_control $p_control  $i_control  if central_move != 1,  absorb(year cityID  ) cluster(cityID)
est store m1


reghdfe sec_promotion $interaction  $prov_control $p_control  $i_control   if  vice_province == 0 ,  absorb(year cityID  ) cluster(cityID)
est store m2

reghdfe sec_promotion $interaction $prov_control $p_control  $i_control   if   winner_sec == 0 ,  absorb(year cityID ) cluster(cityID)
est store m3

outreg2 [m1 m2 m3 ] using "ethnic.tex", replace  $full_spc  drop($p_control $prov_control  $i_control) /// ///
addtext(Prefecture and Year FE, Y,Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y )


*Table F.9 term-level analysis
run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year <2013

collapse ///
(max)  year winner_sec first_con_ps $prov_control provID1 purge_next ///
(last) purge_cen_cum  sec_promotion  sec_promotion_fat con_ps  $i_control  ///
(mean) fiscal_gdp_rel  gdp_pc_rel gdp_growth_rel fiscal_growth_rel ///
, by(name_x cityID)
 
g purgeconnection = first_con_ps*purge_cen_cum

 
lab var sec_promotion "Political Turnover"
lab var cityID "Prefecture"
lab var first_con_ps "Connection"
lab var purge_cen_cum "Purge Intensity"
lab var gdp_growth_rel "Relative GDP Growth Rate"
lab var fiscal_growth_rel "Relative Fiscal Growth Rate"
lab var gdp_pc_rel "Relative Economic Performance"
lab var fiscal_gdp_rel "Relative Fiscal Performance"
lab var sec_age "Age"
lab var sec_age_2 "Age^2"
lab var ps_term "Years in Office"
lab var ps_term_2 "Years in Office^2"
lab var female "Female"
lab var edu "College"
lab var dic "DIC"
lab  var minority "Minority"
lab var law_enforce "Court and Law Enforcement"
lab var org "Organization"
lab var prop "Propaganda"
lab var youth_league "Youth League"
lab var firstjob_yr "Years of Work Experience"
lab var party_yr "Years of Party Membership"
lab var purgeconnection "Purge Intensity*Connection"

balancetable sec_promotion first_con_ps female minority edu sec_age ps_term  firstjob_yr party_yr gdp_pc_rel  fiscal_gdp_rel dic  law_enforce org prop youth_league using "t_test.tex" ,replace varlabel  wide(mean sd pval) pvalues staraux ///
            ctitles("Mean" "SD" "Mean" "SD" "P-value of T-test")


reghdfe sec_promotion $interaction  $i_control    ,  absorb(year cityID) cluster(cityID)
outreg2 using "term_level.tex", replace ctitle(political turnover) keep($interaction) $full_spc ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N)

reghdfe sec_promotion $interaction $p_control $i_control    ,  absorb(year cityID) cluster(cityID)
outreg2 using "term_level.tex", append ctitle(political turnover) keep($interaction) $full_spc ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N)

reghdfe sec_promotion $interaction $prov_control $p_control $i_control  ,  absorb(year cityID  ) cluster(cityID)
outreg2 using "term_level.tex", append ctitle(political turnover) keep($interaction) $full_spc ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y)


* Table F.9 Additional Test: Effect of Performance on Connections


run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year <2013
 
reghdfe gdp_growth_rel first_con_ps      $i_control  ,  absorb(year cityID) cluster(cityID)
est store m1

reghdfe fiscal_growth_rel first_con_ps     $i_control  ,  absorb(year cityID) cluster(cityID)
est store m2

reghdfe sec_dismiss first_con_ps     $i_control  ,  absorb(year cityID) cluster(cityID)
est store m3


outreg2 [m1 m2 m3 ] using "performance_connections.tex", replace  cttop(Patronage Connections) ///
keep( first_con_ps) addtext(Prefecture and Year FE , Y, Individual Controls, Y ) $full_spc


* Table F.10 T test for Connected vs Unconnected

collapse ///
(max)  year winner_sec first_con_ps $prov_control provID1 purge_next ///
(last) purge_cen_cum  sec_promotion  sec_promotion_fat con_ps  $i_control  ///
(mean) fiscal_gdp_rel  gdp_pc_rel gdp_growth_rel fiscal_growth_rel ///
, by(name_x cityID)

asdoc ttest ps_term , by(first_con_ps)


* Table F.11 relationship promotion between purge 

run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year <2013

collapse ///
(max)  year winner_sec first_con_ps $prov_control provID1 purge_next ///
(last) purge_cen_cum  sec_promotion  sec_promotion_fat con_ps  $i_control  ///
(mean) fiscal_gdp_rel  gdp_pc_rel gdp_growth_rel fiscal_growth_rel ///
, by(name_x cityID)

reghdfe purge_next sec_promotion   $i_control    ,  absorb(year cityID) cluster(cityID)
outreg2 using "promotion_purge.tex", replace ctitle(political turnover) keep(sec_promotion) $full_spc ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, N, Provincial Controls, N)


reghdfe purge_next sec_promotion  $p_control  $i_control    ,  absorb(year cityID) cluster(cityID)
outreg2 using "promotion_purge.tex", append ctitle(political turnover) keep(sec_promotion) $full_spc ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, N)


reghdfe purge_next sec_promotion $prov_control   $p_control  $i_control    ,  absorb(year cityID) cluster(cityID)


outreg2 using "promotion_purge.tex", append ctitle(political turnover) keep(sec_promotion) $full_spc ///
addtext(Prefecture and Year FE, Y, Individual Controls, Y, Prefectural Controls, Y, Provincial Controls, Y)



* Table F.11 Alternative Explanation: Cadre Rotation

run /Users/zerenli1992/Dropbox/anti_corruption/replication_file/pre_reg_clean

drop if year <2013

global full_spc_baseline  keep($interaction  $p_control $prov_control prov_ps_exper_inprov) lab  nocons  dec(3)   // alpha(0.01, 0.05, 0.1)

reghdfe  sec_promotion $interaction   $i_control $p_control  $prov_control  prov_ps_exper_inprov ,  absorb(year cityID) cluster(cityID)
est store m1


reghdfe  sec_promotion $interaction   $i_control $p_control  $prov_control  if  prov_ps_exper_inprov == 1  ,  absorb(year cityID) cluster(cityID)
est store m2

reghdfe  sec_promotion $interaction   $i_control $p_control  $prov_control   if  prov_ps_exper_inprov == 0  ,  absorb(year cityID) cluster(cityID)
est store m3

reghdfe  sec_promotion $interaction   $i_control $p_control     ,  absorb(year cityID prov_officerID) cluster(cityID)
est store m4

outreg2 [m1 m2 m3 m4] using "rotation.tex", replace ///
  addtext(Prefecture and Year FE, Y, Individual Controls,Y ) $full_spc_baseline 
